// import _ from 'lodash';
import { mapState, mapMutations } from "vuex";

export default {
  props: {
    value: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      dialogVisible: false,
      formLabelWidth: "80",
      form: {}
    };
  },
  computed: {
    ...mapState(["questionGroupList"])
  },
  watch: {
    value(val) {
      this.dialogVisible = val;
    },
    dialogVisible(val) {
      if (val) {
        this.form = this.resetFormData();
      }
      this.$emit("input", val);
    }
  },
  created() {
    this.form = this.resetFormData();
  },
  methods: {
    ...mapMutations(["addQuestionGroupItem"]),
    submit() {
      this.addQuestionGroupItem(this.submitData);
      this.dialogVisible = false;
    }
    /* getBeginId() {
      return Math.max(0, ...this.questionGroupList.map(item => item.endId)) + 1;
    } */
  }
};
